package org.example.SlApi.JbxxApi;

import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.example.JycInfo;
import org.example.utils.ReadConf;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

import static org.example.CookieHandlingFilter.cookies;
import static org.example.RestClient.givenWithCookies;
import static org.example.RestClient.loginAndUpdateCookies;
import static org.example.SlApi.JbxxApi.QyjbxxbcApi.initJyclist;

public class JbxxeApi { //基本信息二次保存
    public static void main(String[] args) throws IOException {    //基本信息
        JbxxeApi();
    }
    public static int JbxxeApi() throws IOException {
        // 登录并更新cookies

        loginAndUpdateCookies();

        RestAssured.baseURI = ReadConf.getHost(); // 设置基础URI

        List<JycInfo> jycInfoList = initJyclist(); // 调用方法来获取列表
        if (!jycInfoList.isEmpty()) {
            JycInfo firstJycInfo = jycInfoList.get(0); // 获取列表中的第一个元素
            String sbid = firstJycInfo.getSbid();
            String pripid = firstJycInfo.getPripid();
            String data = "ywtSldj.do?method=edit&pripid=" + pripid+ "&sbid=" + sbid +"&select_mkid=1&reslut=&qylxdl=11&csrftoken=";
            Response response = givenWithCookies()


//               .cookies(cookies)


                .get(data); // 注意：可能需要有效的 CSRF Token
        int statusCode = Integer.parseInt(String.valueOf(response.getStatusCode()));
        System.out.println(statusCode);
        String body = response.getBody().asString();
//        System.out.println(body);


        return statusCode;
    }

        return 0;
    }
}
